package com.kclm.se.enums;

/****
 * 交通信号灯的枚举
 * @author yejf
 * @since JDK8.0
 * @CreateDate 2020年8月20日 下午12:16:25 
 * @description 此类用来描述了xxxxx
 *
 */
public enum TrafficLight {

	//相当于：public static final TrafficLight RED = new TrafficLight("红灯")	 { //匿名内部类 }
	RED("红灯") {
		
		@Override
		public TrafficLight next() {
			return GREEN;
		}
	}, 
	
	GREEN("绿灯") {
		
		@Override
		public TrafficLight next() {
			return YELLOW;
		}
	},
	
	YELLOW("黄灯") {
		
		@Override
		public TrafficLight next() {
			return RED;
		}
	};
	
	private String text;
	
	private int duration; //持续的时长,单位为 秒
	
	
	/**
	 * @return the duration
	 */
	public int getDuration() {
		return duration;
	}

	/**
	 * @param duration the duration to set
	 */
	public void setDuration(int duration) {
		this.duration = duration;
	}

	private TrafficLight(String text) {
		this.text = text;
	}
	
	//抽象方法
	public abstract TrafficLight next();

	/**
	 * @return the text
	 */
	public String getText() {
		return text;
	}

	/**
	 * @param text the text to set
	 */
	public void setText(String text) {
		this.text = text;
	}
	
	@Override
	public String toString() {
		return this.text;
	}
}
